package cn.iocoder.yudao.module.resource.api;

import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.infra.util.TraceIdUtil;
import cn.iocoder.yudao.module.resource.api.model.interactionlog.InteractionLogSaveReqDTO;
import cn.iocoder.yudao.module.resource.controller.admin.interactionlog.vo.InteractionLogSaveReqVO;
import cn.iocoder.yudao.module.resource.service.interactionlog.InteractionLogService;
import org.springframework.stereotype.Service;

import jakarta.annotation.Resource;

@Service
public class InteractionLogApiImpl implements IInteractionLogApi {

    @Resource
    private InteractionLogService interactionLogService;

    @Override
    public void asynLog(InteractionLogSaveReqDTO createReqDTO) {
        interactionLogService.asynCreateInteractionLog(BeanUtils.toBean(createReqDTO, InteractionLogSaveReqVO.class));
    }

    @Override
    public void asynLog(Long userId, String gameMatchId, String wsSessionId, String content) {
        final InteractionLogSaveReqDTO log = new InteractionLogSaveReqDTO();
        log.setLogId(IdUtil.objectId());
        log.setUserId(userId);
        log.setWsSessionId(wsSessionId);
        log.setGameMatchId(gameMatchId);
        log.setTraceId(TraceIdUtil.getTraceId());
        log.setContent(content);
        asynLog(log);
    }
}
